if [ "$#" -eq 1 ]
then
  if [ "$1" == "--uninstall" ]
  then
    echo -e "---\e[92mUninstall All\e[0m---"
    rm -rf $HOME/buildnginx
    rm -rf $HOME/nginx-rtmp-module
    exit 0
  fi
fi

if [ `whoami` == "root" ]
then
  apt-get install build-essential fakeroot dpkg-dev
  apt-get build-dep nginx
  exit
fi

mkdir -p $HOME/buildnginx
cd $HOME/buildnginx
apt-get source nginx
cd $HOME/buildnginx/nginx-1.6.2
dpkg-buildpackage -rfakeroot -b
exit
if [ ! -f "/usr/local/nginx/sbin/nginx" ]
then
  echo -e "---\e[92mInstall nginx\e[0m---"
  if [ ! -d "$HOME/nginx" ]
  then
    git clone https://github.com/nginx/nginx.git
  fi
  if [ ! -d "$HOME/nginx-rtmp-module" ]
  then
    git clone https://github.com/arut/nginx-rtmp-module.git
  fi
  cd $HOME/nginx
  #--with-debug
  ./configure --add-module=$HOME/nginx-rtmp-module --with-http_ssl_module
  make
  sudo make install
fi
cd $HOME
if [ ! -d "$HOME/dash.js" ]
then
  git clone https://github.com/arut/dash.js.git
  cd $HOME/dash.js
  git checkout live
fi

